package TCPTest03UploadFile;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10000);
        Socket s = ss.accept();
        //获取输入流
        InputStream inputStream = s.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(inputStream);
        //创建空文件
        File file = new File("E:\\webP\\server\\2.txt");
        if(!file.exists()){
            file.createNewFile();
        }
        //获取文件输出流
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);

        //读取输入流，将内容输出到空文件。
        byte[] bytes = new byte[1024];
        while (bis.read(bytes)!=-1){
            bos.write(bytes);
        }
        //关闭资源
        s.close();
        ss.close();

    }
}
